﻿using System;
using System.Linq;
using AccessControl.Common;
using AccessControl.DataAcess;


namespace AccessControl.Business
{
	public class GroupUserBusiness
		
	{
		private readonly GroupUserAccess _groupUserAccess = new GroupUserAccess();

		public void Insert(AccessControlDS.GroupUserRow row)
		{
			_groupUserAccess.Insert(row);
		}

		public AccessControlDS.GroupUserDataTable SelectAll()
		{
			return _groupUserAccess.SelectAll();
		}

		public AccessControlDS.GroupUserRow SelectByUsername(string userName)
		{
			var searchFilter = String.Format("UserName='{0}'", userName);
			var result = SelectByFilter(searchFilter);
			if((result!=null)&& (result.Rows.Count>0))
			return result.SingleOrDefault();
			return null;
		}

		public AccessControlDS.GroupUserDataTable SelectByFilter(string searchFilter)
		{
			return _groupUserAccess.SelectByFilter(searchFilter);
		}
	}
}
